﻿using System.Collections.Generic;
using System;

namespace AppMain
{
    public class TMHitFallProcesser : BaseMoveProcesser
    {
        protected override void onEnter(RoleMove_Status fromStatus)
        {
            add = 0;
        }

        protected override void onUpdate()
        {
            add = 0;
        }

        protected override void onExit(RoleMove_Status toStatus)
        {

        }

        float add = 0;
        float attPercent = 0.2f;//衰减系数
        float min = 0.05f;//初始值
        float reboundValue = 2f;//反弹值
        protected override void onTick(float frameTime)
        {
            //下落到地板  由慢到快
            //高度>阈值   弹起浮空
            float percent = frameTime / 0.01f;
            float sub = (min + add * attPercent) * attPercent * percent;
            add += sub;
            sub = this.agent.RoleHeight - sub < 0 ? this.agent.RoleHeight : sub;
            this.agent.RoleHeight -= sub;
            this.agent.move(0, 0);

            if (this.agent.RoleHeight <= 0)
            {
                if (add > reboundValue)
                {
                    MoveData moveData = new MoveData();
                    moveData.distance = add * 0.25f;
                    moveData.height = add * 0.25f;
                    moveData.dir.x = this.data.dir.x;
                    moveData.dir.z = this.data.dir.z;
                    moveData.time = 0.6f;
                    moveData.moveStatus = Move_Status.Rebound;
                    this.agent.moveWidget.forceTo(RoleMove_Status.HitCurve, moveData);
                }
                else
                {
                    this.agent.moveWidget.forceTo(RoleMove_Status.LieDown);
                }
            }
        }

        protected override void onDispose()
        {

        }

    }
}
